package cn.bugstack.mybatis.mapping;

import cn.bugstack.mybatis.session.Configuration;

import java.util.Map;

public final class MappedStatement {

    private String id;

    private Configuration configuration;
    private SqlCommandType sqlCommandType;
    private String parameterType;
    private String resultType;
    private String sql;
    private Map<Integer,String> paramter;

    public MappedStatement(){

    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    public void setConfiguration(Configuration configuration) {
        this.configuration = configuration;
    }

    public SqlCommandType getSqlCommandType() {
        return sqlCommandType;
    }

    public void setSqlCommandType(SqlCommandType sqlCommandType) {
        this.sqlCommandType = sqlCommandType;
    }

    public String getParameterType() {
        return parameterType;
    }

    public void setParameterType(String parameterType) {
        this.parameterType = parameterType;
    }

    public String getResultType() {
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public Map<Integer, String> getParamter() {
        return paramter;
    }

    public void setParamter(Map<Integer, String> paramter) {
        this.paramter = paramter;
    }

    public static class Builder{
        private MappedStatement mappedStatement = new MappedStatement();
        public Builder(
                Configuration configuration,
                String id,
                SqlCommandType sqlCommandType,
                String parameterType,
                String resultType,
                String sql,
                Map<Integer,String> paramter){
            mappedStatement.configuration = configuration;
            mappedStatement.id = id;
            mappedStatement.sqlCommandType = sqlCommandType ;
            mappedStatement.parameterType = parameterType;
            mappedStatement.resultType = resultType;
            mappedStatement.sql = sql;
            mappedStatement.paramter = paramter;
        }

        public MappedStatement build() {
            assert mappedStatement.configuration != null;
            assert mappedStatement.id != null;
            assert mappedStatement.sql != null;
            return mappedStatement;
        }
    }
}
